import type { addCartItemRes, addCartParams, GetCartListItemRes } from '@/types/cart'
import { request } from '@/utils/request'
/**
 * 添加购物车
 */

export const addCartAPI = (params: addCartParams) => {
  return request<addCartItemRes>('/member/cart', 'POST', params)
}

/**
 * 获取购物车列表
 */
export const GetCartListAPI = () => {
  return request<GetCartListItemRes[]>('/member/cart', 'GET')
}

/**
 * 删除购物车商品
 */
export const DeleteCartItemAPI = (params: { ids: string[] }) => {
  return request('/member/cart', 'DELETE', params)
}

/**
 * 更新购物车商品
 */
export const putMemberCartBySkuIdAPI = (
  skuId: string,
  params: { selected?: boolean; count?: number },
) => {
  return request(`/member/cart/${skuId}`, 'PUT', params)
}

/**
 * 全选购物车商品
 */
export const putMemberCartSelectedAPI = (params: { select: boolean }) => {
  return request('/member/cart/selected', 'PUT', params)
}
